

package blogs.eidos.cloud.framework.common.dto;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import net.bigdata.cloud.framework.constant.CommonConstant;

import java.io.Serializable;

/**
 * 查询参数
 *
 * @author Eidos
 * @since 2018-11-08
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@Accessors(chain = true)
@ApiModel(value = "BasePageDto", description = "基础分页对象")
public  class BasePageDto implements Serializable {
    private static final long serialVersionUID = -3263921252635611410L;

    @ApiModelProperty(value = "页码,默认为1", example = "1")
    private Integer current = CommonConstant.DEFAULT_PAGE_INDEX;

    @ApiModelProperty(value = "页大小,默认为10", example = "10")
    private Integer pageSize = CommonConstant.DEFAULT_PAGE_SIZE;

//    @ApiModelProperty(value = "总记录数量", example = "0")
//    private Long total = CommonConstant.DEFAULT_PAGE_INDEX;
//
//    @ApiModelProperty(value = "总记录数量", example = "0")
//    private Long pages = CommonConstant.DEFAULT_PAGE_INDEX;


    public void setCurrent(Integer current) {
        if (current == null || current <= 0) {
            this.current = CommonConstant.DEFAULT_PAGE_INDEX;
        } else {
            this.current = current;
        }
    }

    public void setPageSize(Integer size) {
        if (size == null || current <= 0) {
            this.pageSize = CommonConstant.DEFAULT_PAGE_SIZE;
        } else {
            this.pageSize = size;
        }
    }

//    public void setTotal(Long total) {
//        if (total == null || total <= 0) {
//            this.total = CommonConstant.DEFAULT_PAGE_SIZE;
//        } else {
//            this.total = total;
//        }
//
//        if (total == null || total <= 0) {
//            this.total = CommonConstant.DEFAULT_PAGE_SIZE;
//        } else {
//            this.total = total;
//        }
//
//        this.pages = (total + size - 1) / size;
//    }




}
